from __future__ import with_statement
import sys,os,time,simplejson as json
JSON = '''{
  "mac":"00:d0:69:42:75:b9",
  "command": "",
  "repeat": {
    "interval": 0,
    "ifDisconnected": false
  },
  "file": {
    "name": "foo.bar",
    "Content-Type": "text/plain",
    "content": "Helloworld!"
  }
}'''
COMMAND_FILE = '/var/www/command.json'
command = json.loads(JSON)
with open(sys.argv[1]) as f:
    command['file']['content'] = f.read()
command['file']['name'] = sys.argv[2]
with open(COMMAND_FILE,'w') as f:
    f.write(json.dumps(command))
os.system('cat '+sys.argv[2])
print()
